<?php

namespace common\models;

use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\BuyJobUser;

/**
 * BuyJobUserSearch represents the model behind the search form about `common\models\BuyJobUser`.
 */
class BuyJobUserSearch extends BuyJobUser
{
    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['id', 'user_id', 'buyjob_id', 'buy_num', 'create_time'], 'integer'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function scenarios()
    {
        // bypass scenarios() implementation in the parent class
        return Model::scenarios();
    }

    /**
     * Creates data provider instance with search query applied
     *
     * @param array $params
     *
     * @return ActiveDataProvider
     */
    public function search($params)
    {
        $query = BuyJobUser::find();

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);
        
        if (!($this->load($params) && $this->validate())) {
            return $dataProvider;
        }

        $query->andFilterWhere([
            'id' => $this->id,
            'user_id' => $this->user_id,
            'buyjob_id' => $this->buyjob_id,
            'buy_num' => $this->buy_num,
            'create_time' => $this->create_time,
        ]);

        return $dataProvider;
    }
}
